package com.fcscs.cservice.client.common;

import java.util.Date;

import com.extjs.gxt.ui.client.util.DateWrapper;

public class CServiceTimeUtils {
	public static Date resetFindDate(Date date, Date time) {
    	if (date != null) {
        	DateWrapper dw = new DateWrapper(date);
    		if (time == null) {
    			dw.addHours(0);
    			dw.addMinutes(0);
    			dw.addSeconds(0);
    			date = dw.asDate();
    		} else {
    			dw.addHours(dw.getHours());
    			dw.addMinutes(dw.getMinutes());
    			dw.addSeconds(0);
    			date = dw.asDate();
    		}
    	}
    	return date;
    }
	
	@SuppressWarnings("deprecation")
	public static Date setDateStartTime(Date dt) {
		Date newDate;
		if (dt != null) {
			newDate = new Date();
			newDate.setTime(dt.getTime());
			newDate.setHours(0);
			newDate.setMinutes(0);
			newDate.setSeconds(0);
		} else {
			newDate = dt;
		}
		return newDate;
	}

	@SuppressWarnings("deprecation")
	public static Date setDateEndTime(Date dt) {
		Date newDate;
		if (dt != null) {
			newDate = new Date();
			newDate.setTime(dt.getTime());
			newDate.setHours(23);
			newDate.setMinutes(59);
			newDate.setSeconds(59);
		} else {
			newDate = dt;
		}
		return newDate;
	}
}
